<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="person.professional.label_#{logged.loggedIdiom}" var="label" />
                <f:loadBundle basename="person.professional.message_#{logged.loggedIdiom}" var="message" />
                <f:loadBundle basename="person.professional.help_#{logged.loggedIdiom}" var="help" />
                <script>
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>

        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form rendered="#{access.visit}">   
                    <p:growl id="messages" showDetail="true"/> 
                    <div class="field">
                        <h:outputText value="#{label.field1}" class="label"/>
                        <h:selectOneMenu id="pais" value="#{person_professional.id_pais}" required="#{param['required']=='true'}" requiredMessage="#{message.m21}">
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItems value="#{location_countryFind.listItem()}"/>  
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field2}" class="label"/>
                        <h:selectOneMenu value="#{person_professional.idl_cargo}" required="#{param['required']=='true'}" requiredMessage="#{message.m22}"> 
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItem itemLabel="#{label.cargo1}" itemValue="1" />  
                            <f:selectItem itemLabel="#{label.cargo2}" itemValue="2" />  
                            <f:selectItem itemLabel="#{label.cargo3}" itemValue="3" />  
                            <f:selectItem itemLabel="#{label.cargo4}" itemValue="4" /> 
                            <f:selectItem itemLabel="#{label.cargo5}" itemValue="5" /> 
                            <f:selectItem itemLabel="#{label.cargo6}" itemValue="6" />  
                            <f:selectItem itemLabel="#{label.cargo7}" itemValue="7" />  
                            <f:selectItem itemLabel="#{label.cargo8}" itemValue="8" />  
                            <f:selectItem itemLabel="#{label.cargo9}" itemValue="9" /> 
                            <f:selectItem itemLabel="#{label.cargo10}" itemValue="10" /> 
                            <f:selectItem itemLabel="#{label.cargo11}" itemValue="11" /> 
                        </h:selectOneMenu> 
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field3}" class="label"/>
                        <p:calendar value="#{person_professional.inicio}" effect="slide" navigator="true" readonlyInput="true" pattern="dd/MM/yy" size="5"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field4}" class="label"/>
                        <p:calendar value="#{person_professional.fin}" effect="slide" navigator="true" readonlyInput="true" pattern="dd/MM/yy" size="5"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field8}" class="label"/>
                        <h:inputText value="#{person_professional.detalle}" class="textfield" size="35" maxlength="50" required="#{param['required']=='true'}" requiredMessage="#{message.m23}"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field5}" class="label"/>
                        <h:inputText value="#{person_professional.empresa}" class="textfield" size="35" maxlength="50" required="#{param['required']=='true'}" requiredMessage="#{message.m23}"/>
                        <h:outputText class="required" value="*"/>
                    </div>
                    <div class="field">
                        <h:outputText value="#{label.field7}" class="label"/>
                        <h:inputText value="#{person_professional.departamento}" class="textfield" size="50" maxlength="300"/>
                    </div>
                    <div class="field">
                        <h:outputText value="#{label.field6}" class="label"/>
                        <h:inputText value="#{person_professional.referencia}" class="textfield" size="40"/>
                    </div>

                    <h:commandButton value="#{label.button1}" class="button" actionListener="#{person_professional.insert}" rendered="#{access.add}" onclick="return verificar('#{message.m7}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <h:commandButton value="#{label.button2}" class="button" actionListener="#{person_professional.update}" rendered="#{access.update}" onclick="return verificar('#{message.m8}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <h:commandButton value="#{label.button3}" class="button" actionListener="#{person_professional.delete}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')"/>
                    <h:commandButton value="#{label.button4}" class="button" actionListener="#{person_professional.clear}"/>
                </h:form>
                <h:form>
                    <c:set var="list" value="#{person_professionalFind.listByLoggedId}"/>
                    <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list}">
                        <h:dataTable var="p" value="#{list}" class="dataTable">
                            <h:column >
                                <h:commandLink styleClass="editButton" actionListener="#{person_professional.selectedTempId(p.id)}" rendered="#{access.update}" />
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field2}</f:facet>
                                <c:set var="cargo" value="cargo#{p.idl_cargo}" />
                                <h:outputText value="#{label[cargo]}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field8}</f:facet>  
                                <h:outputText value=" #{p.detalle}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field7}</f:facet>  
                                <h:outputText value=" #{p.departamento}  "/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field5}</f:facet>  
                                <h:outputText value=" #{p.empresa}  "/>
                            </h:column>

                            <h:column>
                                <f:facet name="header"   >#{label.field3}</f:facet>  
                                <h:outputText value="  #{p.inicio}  "/>
                            </h:column>
                            <h:column>
                                <f:facet name="header"   >#{label.field4}</f:facet>  
                                <h:outputText value="  #{p.fin}  "/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field6}</f:facet>  
                                <h:outputText value="  #{p.referencia}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field1}</f:facet>
                                <h:outputText value="#{p.countryBeans.nombre}"/>
                            </h:column>
                        </h:dataTable>
                    </h:panelGroup>
                </h:form>
            </h:body>
        </ui:define>

        <!--Segemento donde se define un texto de ayuda para que el usuario pueda utilizar el formulario del contenido-->
        <ui:define name="slideHelper">
            <h3>#{help.title1} </h3>
            #{help.detail1a}
            <p>
                #{help.title2}
                <ul>
                    <li>#{help.detail2a}</li>
                </ul> 
                #{help.title3}
                <ul>
                    <li>#{help.detail3a}</li>
                    <li>#{help.detail3b}</li>
                </ul>
            </p>
        </ui:define>
    </ui:composition>
</html>
